﻿function OpenCom(selectedIndex)
{
    var myDate = new Date();
    //打开串口
    var vcom =  selectedIndex;
    stampocx.ComPort = vcom;
    var ret = stampocx.OpenPort();
    if(ret!=0){
        //alert("打开串口失败");
    }
    return ret;
}

function RunStamp(selectedIndex)
{
    var myDate = new Date();
    var type = selectedIndex;
    stampocx.StampType = type;
    var ret = stampocx.Stamp();
    var res = "执行启动盖章机：";
    switch(ret)
    {
        case 0:
            res += "启动盖章机成功";
            break;
        case -1:
            res += "盖章类型设置错误或串口数据接收失败";
            break;
        case -2:
            res += "校验错误";
            break;
        case -3:
        case -4:
            res += "盖章机错误";
            break;
        case -5:
            res += "盖章机未就绪，不能盖章";
            break;
        case -6:
            res += "盖章机卡纸";
            break;
    }
    if(ret!=0){
        alert(res);
    }
}

function StopStamp()
{
    var myDate = new Date();
    var ret = stampocx.StopStamp();
    var res = "执行停止盖章机：";
    switch(ret)
    {
        case 0:
            res += "停止盖章机成功";
            break;
        case -1:
            res += "盖章完毕后，印章电机仍在运行";
            break;
        case -2:
            res += "停止盖章机失败";
            break;
    }
    if(ret!=0){
        alert(res);
    }
}

function CloseStamp()
{
    var myDate = new Date();
    var ret = stampocx.ClosePort();
    var res = "执行关闭串口：";
    switch(ret)
    {
        case 0:
            res += "关闭串口成功";
            break;
        case -1:
            res += "关闭串口失败";
            break;
    }
    if(ret!=0){
        alert(res);
    }


}


function GetStampStatus()
{
    var myDate = new Date();
    var ret = stampocx.GetStampStatus();
    /*  var res = "获取当前盖章机状态：";
   switch(ret)
   {
       case 0:
       res += "设备就绪";
       break;
       case -1:
       res += "命令成功无返回";
       case -2:
       res += "盖章机卡纸";
       case -3:
       res += "设备忙，正在盖章或正在导纸";
       case -4:
       res +=	"盖章机电子开关打开";
       break;
   }*/
    return ret;
}

function GetStampCount()
{
    return  stampocx.StampCount;
}

function fq_dy() {
    CloseStamp();
    window.location.reload()
}

